/**************************************************************************************
* Component of simpleRTJ regression tests.
**************************************************************************************
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY,  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL RTJ COMPUTING BE LIABLE FOR ANY CLAIM, DAMAGES
* OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Created by:
*       RTJ Computing
**************************************************************************************/
public class TestInitialisation
{
    static int s = 0;
    int i = 0;
    static
    {
        s++;
    }

    {
        i++;
    }

    public TestInitialisation()
    {
        i++;
    }

    static
    {
        s++;
    }

    {
        i++;
    }

    public static void test() throws Exception
    {
        TestInitialisation ti = new TestInitialisation();
        if (ti.i != 3) throw new Exception("INI1");
        // Notice that all <clinit> are run at startup -> therefore s = 3
        if (TestInitialisation.s != 3) throw new Exception("INI2");

        TestI2 ti2 = new TestI2();
        if (ti2.i != 4) throw new Exception("INI3");
        if (TestInitialisation.s != 3) throw new Exception("INI4");

    }

}

class TestI2 extends TestInitialisation
{
    static
    {
        s ++;
    }

    {
        i ++;
    }
}
